/**************************************************************
 *
 * Copyright (c) 2008, ******, All Rights Reserved.
 *
 * 名 称:
 *		log.h
 * 位 置:
 *		inc/pub/log.h
 * 描 述:
 *		公用日志类
 * 备 注:
 *		无
 * 修 改:
 *		2008-09-14  Simon   - 创建
 *
 **************************************************************/

#ifndef __PUB_LOG_H__
#define __PUB_LOG_H__

#include <string>
#include "pub/def.h"

using namespace std;

class Log
{
public:
	static void debug(const char* fmt, ...);
	static void debugFL(const char* file, unsigned line, const char* fmt, ...);
	static void info(const char* fmt, ...);
	static void infoFL(const char* file, unsigned line, const char* fmt, ...);
	static void warn(const char* fmt, ...);
	static void warnFL(const char* file, unsigned line, const char* fmt, ...);
	static void error(const char* fmt, ...);
	static void errorFL(const char* file, unsigned line, const char* fmt, ...);
	static void throwError(const char* fmt, ...);
	static void throwError(unsigned errCode, const char* fmt, ...);
	static void throwErrorFL(const char* file, unsigned line, const char* fmt, ...);
	static void throwErrorFL(unsigned errCode, const char* file, unsigned line, const char* fmt, ...);
	static void setLogTo(int logTo);
	static int getLogTo();
	static void setLogLevel(int logLevel);
	static int getLogLevel();
	static void setLogFile(const char* logFile);
	static const char* getLogFile();

private:
	static void _log(int lvl, int to, const char* file, const char* buff,
			unsigned len);

private:
	static int _logTo;
	static int _logLevel;
	static string _logFile;
};

#endif
